#pragma once
#include <vector>
#include <map>
#include <fstream>
#include "PokemonDefinition.h"

class PokemonLoader
{
#pragma region Singleton
public:
	static PokemonLoader* GetInstance()
	{ 
		if(!m_Instance)
		{
			m_Instance = new PokemonLoader();
		}
		return m_Instance;
	}
	static void Kill()
	{
		delete m_Instance;
		m_Instance = 0;
	}
private:
	static PokemonLoader* m_Instance;
	PokemonLoader();
	PokemonLoader(const PokemonLoader& e);
	~PokemonLoader();
	PokemonLoader& operator=(const PokemonLoader& e);
#pragma endregion

public:
	//Getters
	float GetTypeEffectiveness(int _attacking, int _defending) const { return m_TypeChart[_attacking][_defending]; }
	std::vector<int> GetGroup(GroupDifficulty _group) { return m_Groups[_group]; }
	PokemonData GetPokemonData(int _number) { return m_AllPokemons[_number]; }
	AttackData GetAttackData(const std::string& _attack) { return m_AllAttacks[_attack]; }
	AnimationData GetAnimationData(const AnimationName& _animation) { return m_Animations[_animation]; }
	std::vector<LevelUpData> GetLevelUpChart(int _number) { return m_LevelUpChart[_number]; }

private:
	float m_TypeChart[TYPE_COUNT][TYPE_COUNT];
	std::map<int, PokemonData> m_AllPokemons;
	std::map<std::string, AttackData> m_AllAttacks;
	std::map<int, std::vector<LevelUpData>> m_LevelUpChart;
	std::map<GroupDifficulty, std::vector<int>> m_Groups;
	std::map<AnimationName, AnimationData> m_Animations;
	
	void InitAttacks();
	void InitAnimations();
	void InitTypeChart();
	void InitPokemons();
	void InitGroups();
	void InitPokemonAttackList();

	StatusEffect GetStatusFromStr(const std::string& _status) const;
	PokemonType GetTypeFromStr(const std::string& _type) const;
	AnimationName GetAnimationFromStr( const std::string& _animation) const;
	void EditName(std::string& _name);
};